package com.bgds.sys.data.iXCom29d.protocol.utils;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: lhp
 * @date: 2019/10/8
 **/

public class IXComActionParamDTO {

    /**
     * 属性配置类型
     */
    public enum PropertyType {
        /**
         * 字节
         */
        BYTE,
        /**
         * 布尔
         */
        BOOLEAN,
        /**
         * short
         */
        SHORT,
        /**
         * 整型
         */
        INT,
        /**
         * 单精度
         */
        FLOAT,
        /**
         * 双精度
         */
        DOUBLE,
        /**
         * 字符
         */
        STRING,
        /**
         * 长整型
         */
        LONG,
        /**
         * 占位符
         */
        PLACEHOLDER
    }

    /**
     * 属性列表
     */
    private List<PropertyConfig> propertyList;
    
    /**
     * 是否透传
     */
    private Boolean isPassthrough;
    
	public Boolean getIsPassthrough() {
		return isPassthrough;
	}

	public void setIsPassthrough(Boolean isPassthrough) {
		this.isPassthrough = isPassthrough;
	}

	public void appendProperty(PropertyConfig propertyConfig) {

        if (propertyConfig == null) {
            return;
        }

        if (propertyList == null) {
            propertyList = new ArrayList<>();
        }
        propertyList.add(propertyConfig);
    }

    @Data
    @ToString
    public static class PropertyConfig{
        /** influxDB 表名，MySQL 设备编码，解码用于字段分组*/
	    private String measurementName;
        /** 属性值*/
        private Object value;

        /** 属性Id*/
        private String propertyId;

        /** 属性类型*/
        private PropertyType propertyType;

        /**固定长度*/
        private Integer fixedLength;
        private Integer convertTo;
        /**精度*/
        private Integer precision;

        @ApiModelProperty(value = "mysql的Id")
        private Long id;

        @ApiModelProperty(value = "分组编码")
        private String groupCode;

        @ApiModelProperty(value = "是否报警")
        private Boolean alarmFlag;
        @ApiModelProperty(value = "是否报警")
        private String alarmFilter;

        @ApiModelProperty(value = "名称")
        private String name;





//        public String getPropertyId() {
//            return propertyId;
//        }
//
//        public void setPropertyId(String propertyId) {
//            this.propertyId = propertyId;
//        }
//
//        public PropertyType getPropertyType() {
//            return propertyType;
//        }
//
//        public void setPropertyType(PropertyType propertyType) {
//            this.propertyType = propertyType;
//        }
//
//		public Integer getFixedLength() {
//			return fixedLength;
//		}
//
//		public void setFixedLength(Integer fixedLength) {
//			this.fixedLength = fixedLength;
//		}
//
//		public Integer getPrecision() {
//			return precision;
//		}
//
//		public void setPrecision(Integer precision) {
//			this.precision = precision;
//		}
//
//		@Override
//		public String toString() {
//			return "PropertyConfig [propertyId=" + propertyId + ", propertyType=" + propertyType + ", fixedLength="
//					+ fixedLength + ", precision=" + precision + "]";
//		}
    }

    public List<PropertyConfig> getPropertyList() {
        return propertyList;
    }

    public void setPropertyList(List<PropertyConfig> propertyList) {
        this.propertyList = propertyList;
    }

	@Override
	public String toString() {
		return "IXComActionParamDTO [propertyList=" + propertyList + ", isPassthrough=" + isPassthrough + "]";
	}
}
